﻿using B.S.DataBase.MyProject.Domain;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyRead.API.Appicant.Command.ApproveCommand;
using B.S.DataBase.MyRead.API.DTOs;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.DataBase.MyRead.API.Controllers
{
    /// <summary>
    /// 请假审批模块
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ApproveController : ControllerBase
    {
        private readonly IMediator mediator;

        public ApproveController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        ///  获取上一级领导名称(多人) (部门id,级别) 命令执行
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<User>>> FanTianleaveLeaderName([FromQuery]FanTianleaveLeaderNameCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 获取请假申请集合列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPaing<LeaveModel>> ListLeaveModel([FromQuery]ListLeaveModelCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 获取审批记录(审批人名称  -- 审批结果)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<List<UserLeaveRecordDTOs>>> GetLeaveRecord([FromQuery]GetLeaveRecordCommand request)
        { 
            return await mediator.Send(request);
        }


        /// <summary>
        /// 反填获取审批结果
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<LeaveRecordModel>> FanTianAPPlicant([FromQuery]FanTianAPPlicantStatusCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// (新)获取请假申请集合列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPaing<ListLeaveModelDTOS>> OldListLeaveModel([FromQuery]NewListLeaveModelCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 通过请假申请id查询相关记录表条数 (申请id ==> 记录条数)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<string>> GetLeaveRecordCount([FromQuery]GetLeaveRecordCountCommand request)
        { 
            return await mediator.Send(request);
        }


    }
}
